# -.- coding: utf-8 -.-

from django.db import models
from django.utils.translation import ugettext_lazy as _

# Create your models here.
class Planning(models.Model):
    create_datetime = models.DateTimeField(auto_now_add=True)
    update_datetime = models.DateTimeField(auto_now=True)
    title = models.CharField(max_length=100)
    description = models.TextField()
    active = models.BooleanField(default=False)

    def is_active(self):
        return self.active
    is_active.short_description = 'Is active?'

    def __unicode__(self):
        return self.title
        

class Action(models.Model):
    create_datetime = models.DateTimeField(auto_now_add=True)
    update_datetime = models.DateTimeField(auto_now=True)
    title = models.CharField(max_length=100)
    tags = models.TextField()
    description = models.TextField()
    planning = models.ForeignKey('Planning')
    
    def __unicode__(self):
        return self.title

DAY_OF_WEEK_CHOICES = (
    ('L', 'Lunes'),
    ('M', 'Martes'),
    ('X', 'Miércoles'),
    ('J', 'Jueves'),
    ('V', 'Viernes'),
    ('S', 'Sábado'),
    ('D', 'Domingo'),
)

class TimeSlot(models.Model):
    create_datetime = models.DateTimeField(auto_now_add=True)
    update_datetime = models.DateTimeField(auto_now=True)
    ini_time = models.TimeField()
    end_time = models.TimeField()
    day = models.CharField(max_length=1, choices=DAY_OF_WEEK_CHOICES)
    action = models.ForeignKey('Action')
    
    def __unicode__(self):
        return u'%s - %s' % (self.ini_time, self.end_time)
